package o;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import o.hg.e;

public class vn {
    private final c ˎ;
    private final vo ॱ;

    static class c {
        private final Map<Class<?>, e<?>> ˏ = new HashMap();

        static class e<Model> {
            final List<vk<Model, ?>> ˋ;

            public e(List<vk<Model, ?>> list) {
                this.ˋ = list;
            }
        }

        c() {
        }

        public void ˎ() {
            this.ˏ.clear();
        }

        public <Model> void ˊ(Class<Model> cls, List<vk<Model, ?>> list) {
            if (((e) this.ˏ.put(cls, new e(list))) != null) {
                throw new IllegalStateException("Already cached loaders for model: " + cls);
            }
        }

        @Nullable
        public <Model> List<vk<Model, ?>> ˋ(Class<Model> cls) {
            e eVar = (e) this.ˏ.get(cls);
            return eVar == null ? null : eVar.ˋ;
        }
    }

    public vn(@NonNull e<List<Throwable>> eVar) {
        this(new vo(eVar));
    }

    private vn(@NonNull vo voVar) {
        this.ˎ = new c();
        this.ॱ = voVar;
    }

    public synchronized <Model, Data> void ˎ(@NonNull Class<Model> cls, @NonNull Class<Data> cls2, @NonNull vr<? extends Model, ? extends Data> vrVar) {
        this.ॱ.ˏ(cls, cls2, vrVar);
        this.ˎ.ˎ();
    }

    public synchronized <Model, Data> void ˋ(@NonNull Class<Model> cls, @NonNull Class<Data> cls2, @NonNull vr<? extends Model, ? extends Data> vrVar) {
        ˋ(this.ॱ.ˊ(cls, cls2, vrVar));
        this.ˎ.ˎ();
    }

    private <Model, Data> void ˋ(@NonNull List<vr<? extends Model, ? extends Data>> list) {
        for (vr ॱ : list) {
            ॱ.ॱ();
        }
    }

    @NonNull
    public <A> List<vk<A, ?>> ˊ(@NonNull A a) {
        List ˏ = ˏ(ˎ(a));
        int size = ˏ.size();
        Object obj = 1;
        List<vk<A, ?>> emptyList = Collections.emptyList();
        for (int i = 0; i < size; i++) {
            vk vkVar = (vk) ˏ.get(i);
            if (vkVar.ˋ(a)) {
                if (obj != null) {
                    emptyList = new ArrayList(size - i);
                    obj = null;
                }
                emptyList.add(vkVar);
            }
        }
        return emptyList;
    }

    @NonNull
    public synchronized List<Class<?>> ˋ(@NonNull Class<?> cls) {
        return this.ॱ.ˊ(cls);
    }

    @NonNull
    private synchronized <A> List<vk<A, ?>> ˏ(@NonNull Class<A> cls) {
        List<vk<A, ?>> ˋ;
        ˋ = this.ˎ.ˋ(cls);
        if (ˋ == null) {
            ˋ = Collections.unmodifiableList(this.ॱ.ˏ((Class) cls));
            this.ˎ.ˊ(cls, ˋ);
        }
        return ˋ;
    }

    @NonNull
    private static <A> Class<A> ˎ(@NonNull A a) {
        return a.getClass();
    }
}
